﻿Public Class GemSet
    Implements ICloneable
    ' In addition to holding
    ' item index data, this will also hold gem socket index data.
    ' Trying to keep this down to indexes right now to keep memory usage
    ' fairly low.

    Public itemIDs() As Integer
    Public gemIDs(,) As Integer
    Public wEnch As CalcManager.Enchants
    Public hEnch As CalcManager.Enchants
    Public fench As CalcManager.Enchants
    Public metaGem As metaGems

    Public numPieces As Integer

    Enum metaGems As Integer
        csd
        red
    End Enum

    Public Sub New(ByVal numPiecesIN As Integer)
        ' Make sure everything is correctly sized.
        Try
            numPieces = numPiecesIN
            ReDim itemIDs(0 To numPieces - 1)
            ReDim gemIDs(0 To numPieces - 1, 0 To 2)
        Catch ex As Threading.ThreadAbortException
        Catch ex As Exception
            MessageBox.Show("An unexpected error has occurred. DK Optimize will exit.", "DK Optimize", MessageBoxButtons.OK, MessageBoxIcon.Stop, MessageBoxDefaultButton.Button1)
            ErrLogWriter.writeLog(ex)
            End
        End Try
    End Sub

    Public Function Clone() As Object Implements System.ICloneable.Clone
        Try
            Return New GemSet(numPieces) With {.itemIDs = itemIDs.Clone, .gemIDs = gemIDs.Clone, .wEnch = wEnch, .hEnch = hEnch, .fench = fench, .metaGem = metaGem}
        Catch ex As Threading.ThreadAbortException
            Return New GemSet(numPieces) With {.itemIDs = itemIDs.Clone, .gemIDs = gemIDs.Clone, .wEnch = wEnch, .hEnch = hEnch, .fench = fench, .metaGem = metaGem}
        Catch ex As Exception
            MessageBox.Show("An unexpected error has occurred. DK Optimize will exit.", "DK Optimize", MessageBoxButtons.OK, MessageBoxIcon.Stop, MessageBoxDefaultButton.Button1)
            ErrLogWriter.writeLog(ex)
            End
        End Try
    End Function

    Public Sub clearGem(ByVal slotIndex As Integer, ByVal socketIndex As Integer)
        Try
            gemIDs(slotIndex, socketIndex) = -1
        Catch ex As Threading.ThreadAbortException
        Catch ex As Exception
            MessageBox.Show("An unexpected error has occurred. DK Optimize will exit.", "DK Optimize", MessageBoxButtons.OK, MessageBoxIcon.Stop, MessageBoxDefaultButton.Button1)
            ErrLogWriter.writeLog(ex)
            End
        End Try
    End Sub

End Class
